<?php
/**
*   常见问题
*/
namespace app\api\model;
use think\Model;

class Problem extends Model
{
    /**
    *   常见问题列表
    */
    public function _list($where = 'status = 1', $order_by="sort asc", $page_size = PAGE_SIZE_API){
        $obj = $this->order($order_by);
        $data = $this->where($where)
            ->field('id, title, content, type')
            ->order($order_by)
            ->paginate($page_size)
            ->toArray();
        return $data;
    }
    
    /**
    * 通过id获取内容
    * @param id int 地址id
    * @return string 地址名
    */
    public function _getProblemById($id){
        $data = $this->field('id, title, content')->where([['id', '=', $id], ['status', '=', 1]])->find();
        if(empty($data)){
            $this->error = '该问题不存在';
            return false;
        }
        
        
        return $data;
    }
    

}